﻿using System;
using System.Collections;

namespace NHEntity.PK
{
    [Serializable]
    public class PKUserRole : IEquatable<PKUserRole>
    {
        private UserEntity idUser = new UserEntity();
        private RoleEntity idRole = new RoleEntity();
        private readonly CaseInsensitiveComparer objComparer  = new CaseInsensitiveComparer();
        public virtual UserEntity IdUser
        {
            set
            {
                idUser = value;
            }
            get
            {
                return idUser;
            }
        }
        public virtual RoleEntity IdRole
        {
            set
            {
                idRole = value;   
            }
            get
            {
                return idRole;
            }
        }
        public bool Equals(PKUserRole obj)
        {
            return objComparer.Compare(this, obj) == 0;
        }
        public override bool Equals(object obj)
        {
            return obj.Equals(this);
        }

        public override int GetHashCode()
        {
            return base.ToString().ToLowerInvariant().GetHashCode() + 1;
        } 
    }
}